# different bandwidths
migbw <- rdd_data(ESS10$mig, ESS10$date, cutpoint = 0, covar = ESS10$cntry)
migbw1 <- rdd_reg_lm(migbw, bw = 14, covariates = "ESS10$cntry") 
summary(migbw1)
migbwplot <- plotSensi(migbw1, 1, 50, order = 1, output= "ggplot")

ecobw <- rdd_data(ESS10$eco, ESS10$date, cutpoint = 0, covar = ESS10$cntry)
ecobw1 <- rdd_reg_lm(ecobw, bw = 14, covariates = "ESS10$cntry")
summary(ecobw1)
ecobwplot <- plotSensi(ecobw1, 1, 50, order = 1, output= "ggplot")

culbw <- rdd_data(ESS10$cul, ESS10$date, cutpoint = 0, covar = ESS10$cntry)
culbw1 <- rdd_reg_lm(culbw, bw = 14, covariates = "ESS10$cntry")
summary(culbw1)
culbwplot <- plotSensi(culbw1, 1, 50, order = 1, output= "ggplot")

migbwplot <- migbwplot +
  ggtitle("Overall") +
  theme_light(base_size = 30)

ecobwplot <- ecobwplot +
  ggtitle("Economy") +
  theme_light(base_size = 30)

culbwplot <- culbwplot +
  ggtitle("Culture") +
  theme_light(base_size = 30)

ggarrange(migbwplot, ecobwplot, culbwplot, nrow = 1)


# different bandwidths with 2nd order polynomials
migbwplot2 <- plotSensi(migbw1, 1, 50, order = 2, output= "ggplot")

ecobwplot2 <- plotSensi(ecobw1, 1, 50, order = 2, output= "ggplot")

culbwplot2 <- plotSensi(culbw1, 1, 50, order = 2, output= "ggplot")

migbwplot2 <- migbwplot2 +
  ggtitle("Overall") +
  theme_light(base_size = 30)

ecobwplot2 <- ecobwplot2 +
  ggtitle("Economy") +
  theme_light(base_size = 30)

culbwplot2 <- culbwplot2 +
  ggtitle("Culture") +
  theme_light(base_size = 30)

ggarrange(migbwplot2, ecobwplot2, culbwplot2, nrow = 1)



# different bandwidths with 3rd order polynomials
migbwplot3 <- plotSensi(migbw1, 1, 50, order = 3, output= "ggplot")

ecobwplot3 <- plotSensi(ecobw1, 1, 50, order = 3, output= "ggplot")

culbwplot3 <- plotSensi(culbw1, 1, 50, order = 3, output= "ggplot")

migbwplot3 <- migbwplot3 +
  ggtitle("Overall") +
  theme_light(base_size = 30)

ecobwplot3 <- ecobwplot3 +
  ggtitle("Economy") +
  theme_light(base_size = 30)

culbwplot3 <- culbwplot3 +
  ggtitle("Culture") +
  theme_light(base_size = 30)

ggarrange(migbwplot3, ecobwplot3, culbwplot3, nrow = 1)



